/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.date.DatePattern
 *  cn.hutool.core.date.DateUtil
 *  cn.hutool.core.date.format.DatePrinter
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.Button
 *  javafx.scene.control.CheckBox
 *  javafx.scene.control.DatePicker
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.Pane
 *  javafx.stage.Stage
 *  javafx.util.StringConverter
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.util.CollectionUtils
 *  org.springframework.util.StringUtils
 */
package com.gys.controller.deviceInfo;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.format.DatePrinter;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.DeviceInfoUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.CacheUtil;
import com.gys.common.util.CommonUtil;
import com.gys.controller.BaseController;
import com.gys.controller.deviceInfo.DeviceInfoController;
import com.gys.data.deviceInfo.DeviceInfoInData;
import com.gys.data.deviceInfo.DeviceInfoOutData;
import com.gys.data.example.GetLoginStoreOutData;
import com.gys.data.example.GetUserOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.util.Date;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.util.StringConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

@FXMLController
public class EditDeviceInfoController
extends BaseController
implements Initializable {
    @FXML
    private Button editBtn;
    @FXML
    private Button cancelBth;
    @FXML
    private Pane modelPane;
    @FXML
    private TextField inpGsdiName;
    @FXML
    private TextField gsthBrId;
    @FXML
    private TextField gsthBrName;
    @FXML
    private TextField inpGsdiModel;
    @FXML
    private TextField inpGsdiFactory;
    @FXML
    private TextField gsdiId;
    @FXML
    private DatePicker inpGsdiStartDate;
    @FXML
    private TextField inpGsdiQty;
    @FXML
    private CheckBox gsdiInstructionCbx;
    @FXML
    private CheckBox gsdiQualifyCbx;
    @FXML
    private CheckBox gsdiCheckCbx;
    @FXML
    private Stage stg;
    @Autowired
    private DeviceInfoController deviceInfoController;

    public void initialize(URL location, ResourceBundle resources) {
        StringConverter converter = CommonUtil.dataPickerFormat("yyyyMMdd");
        this.inpGsdiStartDate.setConverter(converter);
        this.initResource();
    }

    public DeviceInfoOutData getSelectIndex() {
        DeviceInfoOutData outData = new DeviceInfoOutData();
        if (!CollectionUtils.isEmpty(this.deviceInfoController.getObservableTableList())) {
            for (DeviceInfoOutData i : this.deviceInfoController.getObservableTableList()) {
                if (!i.getDeviceInfoCheckBox().isSelected().booleanValue()) continue;
                outData = i;
            }
        }
        return outData;
    }

    private void initResource() {
        DeviceInfoOutData outDataTemp = this.getSelectIndex();
        DeviceInfoOutData outData = new DeviceInfoOutData();
        DeviceInfoInData inData = new DeviceInfoInData();
        inData.setClientId(outDataTemp.getClientId());
        inData.setGsdiId(outDataTemp.getGsdiId());
        HttpJson rsp = DeviceInfoUtil.getDeviceInfo(inData);
        if (!rsp.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
            return;
        }
        outData = (DeviceInfoOutData)JSON.parseObject((String)rsp.getMsg(), DeviceInfoOutData.class);
        if (ObjectUtil.isNotEmpty(outData)) {
            this.gsthBrId.setText(outData.getGsthBrId());
            this.gsthBrId.setEditable(false);
            this.gsthBrName.setText(outData.getGsthBrName());
            this.gsthBrName.setEditable(false);
            this.gsdiId.setText(outData.getGsdiId());
            this.inpGsdiName.setText(outData.getGsdiName());
            this.inpGsdiModel.setText(outData.getGsdiModel());
            this.inpGsdiFactory.setText(outData.getGsdiFactory());
            DecimalFormat decimalFormat = new DecimalFormat("##########.##########");
            if (ObjectUtil.isNotEmpty(outData.getGsdiStartDate())) {
                String pdsYear = outData.getGsdiStartDate().substring(0, 4);
                String pdsMonth = outData.getGsdiStartDate().substring(4, 6);
                String pdsDay = outData.getGsdiStartDate().substring(6);
                this.inpGsdiStartDate.setValue(LocalDate.of((int)Integer.valueOf(pdsYear), Integer.valueOf(pdsMonth), (int)Integer.valueOf(pdsDay)));
            }
            this.inpGsdiQty.setText(outData.getGsdiQty());
            if ("1".equals(outData.getGsdiInstruction())) {
                this.gsdiInstructionCbx.setSelected(true);
            }
            if ("1".equals(outData.getGsdiQualify())) {
                this.gsdiQualifyCbx.setSelected(true);
            }
            if ("1".equals(outData.getGsdiCheck())) {
                this.gsdiCheckCbx.setSelected(true);
            }
        }
    }

    private void initPane() {
        this.gsthBrId.clear();
        this.gsthBrName.clear();
        this.inpGsdiName.clear();
        this.inpGsdiModel.clear();
        this.inpGsdiFactory.clear();
        this.inpGsdiStartDate.setValue(null);
        this.inpGsdiQty.clear();
        this.gsdiInstructionCbx.setSelected(false);
        this.gsdiQualifyCbx.setSelected(false);
        this.gsdiCheckCbx.setSelected(false);
    }

    @Override
    public void init() {
        if (ObjectUtil.isNotEmpty(this.editBtn)) {
            this.initPane();
            this.initResource();
        }
    }

    @FXML
    private void editDeviceInfo() {
        String gsdiIdTemp = this.gsdiId.getText().trim();
        String gsdiName = this.inpGsdiName.getText().trim();
        String gsdiModel = this.inpGsdiModel.getText().trim();
        String gsdiFactory = this.inpGsdiFactory.getText().trim();
        String gsdiStartDate = "";
        if (ObjectUtil.isNotEmpty(this.inpGsdiStartDate.getValue())) {
            gsdiStartDate = DateUtil.format((Date)DateUtil.parse((String)((LocalDate)this.inpGsdiStartDate.getValue()).toString()), (String)"yyyyMMdd");
        }
        String gsdiQty = this.inpGsdiQty.getText().trim();
        Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
        if (StringUtils.isEmpty(gsdiName)) {
            alert.setContentText("\u8bbe\u5907\u540d\u79f0\u4e0d\u53ef\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        if (StringUtils.isEmpty(gsdiQty)) {
            alert.setContentText("\u6570\u91cf\u4e0d\u53ef\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        DeviceInfoInData inData = new DeviceInfoInData();
        inData.setClientId(((GetUserOutData)CacheUtil.get("logInUser")).getClient());
        inData.setGsthBrId(((GetLoginStoreOutData)CacheUtil.get("store")).getStoCode());
        inData.setGsthBrName(((GetLoginStoreOutData)CacheUtil.get("store")).getStoName());
        inData.setGsdiId(gsdiIdTemp);
        inData.setGsdiName(gsdiName);
        inData.setGsdiQty(gsdiQty);
        inData.setGsdiModel(gsdiModel);
        inData.setGsdiFactory(gsdiFactory);
        inData.setGsdiStartDate(gsdiStartDate);
        inData.setGsdiUpdateDat(DateUtil.format((Date)new Date(), (DatePrinter)DatePattern.PURE_DATE_FORMAT));
        inData.setGsthUpdateEmp(((GetUserOutData)CacheUtil.get("logInUser")).getUserId());
        if (this.gsdiInstructionCbx.isSelected()) {
            inData.setGsdiInstruction("1");
        } else {
            inData.setGsdiInstruction("0");
        }
        if (this.gsdiQualifyCbx.isSelected()) {
            inData.setGsdiQualify("1");
        } else {
            inData.setGsdiQualify("0");
        }
        if (this.gsdiCheckCbx.isSelected()) {
            inData.setGsdiCheck("1");
        } else {
            inData.setGsdiCheck("0");
        }
        HttpJson rsp = DeviceInfoUtil.editDeviceInfo(inData);
        if (rsp.isSuccess()) {
            alert.setContentText("\u4fdd\u5b58\u6210\u529f");
            alert.showAndWait();
            this.closeWindow();
            this.deviceInfoController.initTable(0);
            this.deviceInfoController.getPagination().setCurrentPageIndex(0);
        } else {
            alert.setContentText("\u4fdd\u5b58\u5931\u8d25");
            alert.showAndWait();
        }
    }

    @FXML
    private void closeWindow() {
        this.modelPane.getScene().getWindow().hide();
    }

    public Button getEditBtn() {
        return this.editBtn;
    }

    public Button getCancelBth() {
        return this.cancelBth;
    }

    public Pane getModelPane() {
        return this.modelPane;
    }

    public TextField getInpGsdiName() {
        return this.inpGsdiName;
    }

    public TextField getGsthBrId() {
        return this.gsthBrId;
    }

    public TextField getGsthBrName() {
        return this.gsthBrName;
    }

    public TextField getInpGsdiModel() {
        return this.inpGsdiModel;
    }

    public TextField getInpGsdiFactory() {
        return this.inpGsdiFactory;
    }

    public TextField getGsdiId() {
        return this.gsdiId;
    }

    public DatePicker getInpGsdiStartDate() {
        return this.inpGsdiStartDate;
    }

    public TextField getInpGsdiQty() {
        return this.inpGsdiQty;
    }

    public CheckBox getGsdiInstructionCbx() {
        return this.gsdiInstructionCbx;
    }

    public CheckBox getGsdiQualifyCbx() {
        return this.gsdiQualifyCbx;
    }

    public CheckBox getGsdiCheckCbx() {
        return this.gsdiCheckCbx;
    }

    public Stage getStg() {
        return this.stg;
    }

    public DeviceInfoController getDeviceInfoController() {
        return this.deviceInfoController;
    }

    public void setEditBtn(Button editBtn) {
        this.editBtn = editBtn;
    }

    public void setCancelBth(Button cancelBth) {
        this.cancelBth = cancelBth;
    }

    public void setModelPane(Pane modelPane) {
        this.modelPane = modelPane;
    }

    public void setInpGsdiName(TextField inpGsdiName) {
        this.inpGsdiName = inpGsdiName;
    }

    public void setGsthBrId(TextField gsthBrId) {
        this.gsthBrId = gsthBrId;
    }

    public void setGsthBrName(TextField gsthBrName) {
        this.gsthBrName = gsthBrName;
    }

    public void setInpGsdiModel(TextField inpGsdiModel) {
        this.inpGsdiModel = inpGsdiModel;
    }

    public void setInpGsdiFactory(TextField inpGsdiFactory) {
        this.inpGsdiFactory = inpGsdiFactory;
    }

    public void setGsdiId(TextField gsdiId) {
        this.gsdiId = gsdiId;
    }

    public void setInpGsdiStartDate(DatePicker inpGsdiStartDate) {
        this.inpGsdiStartDate = inpGsdiStartDate;
    }

    public void setInpGsdiQty(TextField inpGsdiQty) {
        this.inpGsdiQty = inpGsdiQty;
    }

    public void setGsdiInstructionCbx(CheckBox gsdiInstructionCbx) {
        this.gsdiInstructionCbx = gsdiInstructionCbx;
    }

    public void setGsdiQualifyCbx(CheckBox gsdiQualifyCbx) {
        this.gsdiQualifyCbx = gsdiQualifyCbx;
    }

    public void setGsdiCheckCbx(CheckBox gsdiCheckCbx) {
        this.gsdiCheckCbx = gsdiCheckCbx;
    }

    public void setStg(Stage stg) {
        this.stg = stg;
    }

    public void setDeviceInfoController(DeviceInfoController deviceInfoController) {
        this.deviceInfoController = deviceInfoController;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof EditDeviceInfoController)) {
            return false;
        }
        EditDeviceInfoController other = (EditDeviceInfoController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        Button this$editBtn = this.getEditBtn();
        Button other$editBtn = other.getEditBtn();
        if (this$editBtn == null ? other$editBtn != null : !this$editBtn.equals(other$editBtn)) {
            return false;
        }
        Button this$cancelBth = this.getCancelBth();
        Button other$cancelBth = other.getCancelBth();
        if (this$cancelBth == null ? other$cancelBth != null : !this$cancelBth.equals(other$cancelBth)) {
            return false;
        }
        Pane this$modelPane = this.getModelPane();
        Pane other$modelPane = other.getModelPane();
        if (this$modelPane == null ? other$modelPane != null : !this$modelPane.equals(other$modelPane)) {
            return false;
        }
        TextField this$inpGsdiName = this.getInpGsdiName();
        TextField other$inpGsdiName = other.getInpGsdiName();
        if (this$inpGsdiName == null ? other$inpGsdiName != null : !this$inpGsdiName.equals(other$inpGsdiName)) {
            return false;
        }
        TextField this$gsthBrId = this.getGsthBrId();
        TextField other$gsthBrId = other.getGsthBrId();
        if (this$gsthBrId == null ? other$gsthBrId != null : !this$gsthBrId.equals(other$gsthBrId)) {
            return false;
        }
        TextField this$gsthBrName = this.getGsthBrName();
        TextField other$gsthBrName = other.getGsthBrName();
        if (this$gsthBrName == null ? other$gsthBrName != null : !this$gsthBrName.equals(other$gsthBrName)) {
            return false;
        }
        TextField this$inpGsdiModel = this.getInpGsdiModel();
        TextField other$inpGsdiModel = other.getInpGsdiModel();
        if (this$inpGsdiModel == null ? other$inpGsdiModel != null : !this$inpGsdiModel.equals(other$inpGsdiModel)) {
            return false;
        }
        TextField this$inpGsdiFactory = this.getInpGsdiFactory();
        TextField other$inpGsdiFactory = other.getInpGsdiFactory();
        if (this$inpGsdiFactory == null ? other$inpGsdiFactory != null : !this$inpGsdiFactory.equals(other$inpGsdiFactory)) {
            return false;
        }
        TextField this$gsdiId = this.getGsdiId();
        TextField other$gsdiId = other.getGsdiId();
        if (this$gsdiId == null ? other$gsdiId != null : !this$gsdiId.equals(other$gsdiId)) {
            return false;
        }
        DatePicker this$inpGsdiStartDate = this.getInpGsdiStartDate();
        DatePicker other$inpGsdiStartDate = other.getInpGsdiStartDate();
        if (this$inpGsdiStartDate == null ? other$inpGsdiStartDate != null : !this$inpGsdiStartDate.equals(other$inpGsdiStartDate)) {
            return false;
        }
        TextField this$inpGsdiQty = this.getInpGsdiQty();
        TextField other$inpGsdiQty = other.getInpGsdiQty();
        if (this$inpGsdiQty == null ? other$inpGsdiQty != null : !this$inpGsdiQty.equals(other$inpGsdiQty)) {
            return false;
        }
        CheckBox this$gsdiInstructionCbx = this.getGsdiInstructionCbx();
        CheckBox other$gsdiInstructionCbx = other.getGsdiInstructionCbx();
        if (this$gsdiInstructionCbx == null ? other$gsdiInstructionCbx != null : !this$gsdiInstructionCbx.equals(other$gsdiInstructionCbx)) {
            return false;
        }
        CheckBox this$gsdiQualifyCbx = this.getGsdiQualifyCbx();
        CheckBox other$gsdiQualifyCbx = other.getGsdiQualifyCbx();
        if (this$gsdiQualifyCbx == null ? other$gsdiQualifyCbx != null : !this$gsdiQualifyCbx.equals(other$gsdiQualifyCbx)) {
            return false;
        }
        CheckBox this$gsdiCheckCbx = this.getGsdiCheckCbx();
        CheckBox other$gsdiCheckCbx = other.getGsdiCheckCbx();
        if (this$gsdiCheckCbx == null ? other$gsdiCheckCbx != null : !this$gsdiCheckCbx.equals(other$gsdiCheckCbx)) {
            return false;
        }
        Stage this$stg = this.getStg();
        Stage other$stg = other.getStg();
        if (this$stg == null ? other$stg != null : !this$stg.equals(other$stg)) {
            return false;
        }
        DeviceInfoController this$deviceInfoController = this.getDeviceInfoController();
        DeviceInfoController other$deviceInfoController = other.getDeviceInfoController();
        return !(this$deviceInfoController == null ? other$deviceInfoController != null : !(this$deviceInfoController).equals(other$deviceInfoController));
    }

    protected boolean canEqual(Object other) {
        return other instanceof EditDeviceInfoController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        Button $editBtn = this.getEditBtn();
        result = result * 59 + ($editBtn == null ? 43 : $editBtn.hashCode());
        Button $cancelBth = this.getCancelBth();
        result = result * 59 + ($cancelBth == null ? 43 : $cancelBth.hashCode());
        Pane $modelPane = this.getModelPane();
        result = result * 59 + ($modelPane == null ? 43 : $modelPane.hashCode());
        TextField $inpGsdiName = this.getInpGsdiName();
        result = result * 59 + ($inpGsdiName == null ? 43 : $inpGsdiName.hashCode());
        TextField $gsthBrId = this.getGsthBrId();
        result = result * 59 + ($gsthBrId == null ? 43 : $gsthBrId.hashCode());
        TextField $gsthBrName = this.getGsthBrName();
        result = result * 59 + ($gsthBrName == null ? 43 : $gsthBrName.hashCode());
        TextField $inpGsdiModel = this.getInpGsdiModel();
        result = result * 59 + ($inpGsdiModel == null ? 43 : $inpGsdiModel.hashCode());
        TextField $inpGsdiFactory = this.getInpGsdiFactory();
        result = result * 59 + ($inpGsdiFactory == null ? 43 : $inpGsdiFactory.hashCode());
        TextField $gsdiId = this.getGsdiId();
        result = result * 59 + ($gsdiId == null ? 43 : $gsdiId.hashCode());
        DatePicker $inpGsdiStartDate = this.getInpGsdiStartDate();
        result = result * 59 + ($inpGsdiStartDate == null ? 43 : $inpGsdiStartDate.hashCode());
        TextField $inpGsdiQty = this.getInpGsdiQty();
        result = result * 59 + ($inpGsdiQty == null ? 43 : $inpGsdiQty.hashCode());
        CheckBox $gsdiInstructionCbx = this.getGsdiInstructionCbx();
        result = result * 59 + ($gsdiInstructionCbx == null ? 43 : $gsdiInstructionCbx.hashCode());
        CheckBox $gsdiQualifyCbx = this.getGsdiQualifyCbx();
        result = result * 59 + ($gsdiQualifyCbx == null ? 43 : $gsdiQualifyCbx.hashCode());
        CheckBox $gsdiCheckCbx = this.getGsdiCheckCbx();
        result = result * 59 + ($gsdiCheckCbx == null ? 43 : $gsdiCheckCbx.hashCode());
        Stage $stg = this.getStg();
        result = result * 59 + ($stg == null ? 43 : $stg.hashCode());
        DeviceInfoController $deviceInfoController = this.getDeviceInfoController();
        result = result * 59 + ($deviceInfoController == null ? 43 : ($deviceInfoController).hashCode());
        return result;
    }

    public String toString() {
        return "EditDeviceInfoController(editBtn=" + this.getEditBtn() + ", cancelBth=" + this.getCancelBth() + ", modelPane=" + this.getModelPane() + ", inpGsdiName=" + this.getInpGsdiName() + ", gsthBrId=" + this.getGsthBrId() + ", gsthBrName=" + this.getGsthBrName() + ", inpGsdiModel=" + this.getInpGsdiModel() + ", inpGsdiFactory=" + this.getInpGsdiFactory() + ", gsdiId=" + this.getGsdiId() + ", inpGsdiStartDate=" + this.getInpGsdiStartDate() + ", inpGsdiQty=" + this.getInpGsdiQty() + ", gsdiInstructionCbx=" + this.getGsdiInstructionCbx() + ", gsdiQualifyCbx=" + this.getGsdiQualifyCbx() + ", gsdiCheckCbx=" + this.getGsdiCheckCbx() + ", stg=" + this.getStg() + ", deviceInfoController=" + this.getDeviceInfoController() + ")";
    }
}

